package com.ming.interview;

import java.util.Scanner;

/**
 * @Description 一球从h米高度自由落下，每次落地后反跳回原高度的一半，再落下，求它在 第n次落地时，共经过多少米？第n次反弹多高？
 * @Author ye.ming
 * @Date Created in 2019/8/26
 */
public class Main9 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        int n = sc.nextInt();

        m1(h, n);

    }


    private static void m1(double h, int n) {
        Double sum = h;
        Double temp = h;
        if (n < 2) {
            System.out.println("最后落地走过的路程为：" + h);
            System.out.println("最后弹起的高度为：" + h * 0.5);
        }

        for (int i = 1; i < n; i++) {
            temp = temp * 0.5;
            sum += temp * 2;
        }
        System.out.println("最后落地走过的路程为：" + sum);
        System.out.println("最后弹起的高度为：" + temp * 0.5);

    }


}
